<template>
  <div>
    <div>
      <van-nav-bar
              title="商品详情"
              left-text="返回"
              left-arrow
              @click-left="tzback()"
      />
    </div>
    <!--  1.购物车商品信息-->
    <div>
      <van-swipe-cell v-for="cart in ticketscarts">
        <van-row>
          <van-col :span="2">
<!--            <van-radio-group v-model="checked">-->
<!--              <van-radio :name="cart.id"></van-radio>-->
<!--            </van-radio-group>-->
            <van-checkbox v-model="checked"></van-checkbox>
          </van-col>
          <van-col :span="22">
            <van-card
                    :price="cart.price"
                    :desc="cart.detail"
                    :title="cart.title"
                    :thumb="cart.imgurl"
            >
              <template #tags>
                <van-tag plain type="danger">好玩</van-tag>
                <van-tag plain type="danger">不贵</van-tag>
              </template>
              <template #num>
                <van-stepper v-model="cart.num" theme="round" button-size="22" disable-input @change="changeNum(cart)" />
              </template>
            </van-card>
          </van-col>

        </van-row>
        <template #right>
          <van-button square text="删除" type="danger" style="height: 100%" @click="del(cart.id)" class="delete-button" />
        </template>
      </van-swipe-cell>
    </div>
    <!--  2.底部-->
    <div>
      <van-submit-bar :price="3050" button-text="结算" @submit="tzorderpre()">
        <van-checkbox v-model="checked">全选</van-checkbox>
      </van-submit-bar>
    </div>
  </div>
</template>

<script>
  export default {
    name: "TicketCart",
    data(){
      return{
        checked:false,
        ticketscarts:[

        ]
      }
    },mounted() {
      //请求接口
      this.axios.get("/api/cart/my.do?uid="+this.$store.state.user.id).then(res=>{
        if(res.data.code==200){
          this.ticketscarts=res.data.data;
        }
      });
    },methods:{
      tzback(){
        history.back();
      },
      tzorderpre(){
        //跳转到订单预览页
        //存储数据 VueX
        this.$router.push("/ticketorderprefix");
      },
      changeNum(obj){
        //改变
        this.axios.get("/api/cart/change.do?id="+obj.id+"&num="+obj.num).then(res=>{
          if(res.data.code==200){
            //成功

          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
